#include <iostream>
using namespace std;

const int N = 1000010;
int n, m;    //获取输入
int q[N];    //存约数
int cnt = 0; //存约数数目

void quick_sort(int q[], int l, int r)
{
    if (l >= r)
        return;
    int i = l - 1, j = r + 1, x = q[l + r >> 1];
    while (i < j)
    {
        do
            ++i;
        while (q[i] < x);
        do
            --j;
        while (q[j] > x);
        if (i < j)
            swap(q[i], q[j]);
    }
    quick_sort(q, l, j), quick_sort(q, j + 1, r);
    return;
}

int main()
{
    cin >> m;
    while (m--)
    {
        cin >> n;
        cnt = 0;
        for (int i = 1; i <= n / i; ++i)
            if (n % i == 0)
                if (i != n / i)
                    q[cnt++] = i, q[cnt++] = n / i;
                else
                    q[cnt++] = i;
        quick_sort(q, 0, cnt - 1);
        for (int i = 0; i < cnt; ++i)
            cout << q[i] << " ";
        cout << endl;
    }
}